package com.xmy.solution.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xmy.common.annotation.Log;
import com.xmy.common.core.controller.BaseController;
import com.xmy.common.core.domain.AjaxResult;
import com.xmy.common.enums.BusinessType;
import com.xmy.solution.domain.solutionCategory;
import com.xmy.solution.service.IsolutionCategoryService;
import com.xmy.common.utils.poi.ExcelUtil;
import com.xmy.common.core.page.TableDataInfo;

/**
 * 方案分类关系Controller
 * 
 * @author 夏明毅
 * @date 2024-12-29
 */
@RestController
@RequestMapping("/solution/solutionCategory")
public class solutionCategoryController extends BaseController
{
    @Autowired
    private IsolutionCategoryService solutionCategoryService;

    /**
     * 查询方案分类关系列表
     */
    @PreAuthorize("@ss.hasPermi('solution:solutionCategory:list')")
    @GetMapping("/list")
    public TableDataInfo list(solutionCategory solutionCategory)
    {
        startPage();
        List<solutionCategory> list = solutionCategoryService.selectsolutionCategoryList(solutionCategory);
        return getDataTable(list);
    }

    /**
     * 导出方案分类关系列表
     */
    @PreAuthorize("@ss.hasPermi('solution:solutionCategory:export')")
    @Log(title = "方案分类关系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, solutionCategory solutionCategory)
    {
        List<solutionCategory> list = solutionCategoryService.selectsolutionCategoryList(solutionCategory);
        ExcelUtil<solutionCategory> util = new ExcelUtil<solutionCategory>(solutionCategory.class);
        util.exportExcel(response, list, "方案分类关系数据");
    }

    /**
     * 获取方案分类关系详细信息
     */
    @PreAuthorize("@ss.hasPermi('solution:solutionCategory:query')")
    @GetMapping(value = "/{solutionId}")
    public AjaxResult getInfo(@PathVariable("solutionId") Long solutionId)
    {
        return success(solutionCategoryService.selectsolutionCategoryBySolutionId(solutionId));
    }

    /**
     * 新增方案分类关系
     */
    @PreAuthorize("@ss.hasPermi('solution:solutionCategory:add')")
    @Log(title = "方案分类关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody solutionCategory solutionCategory)
    {
        return toAjax(solutionCategoryService.insertsolutionCategory(solutionCategory));
    }

    /**
     * 修改方案分类关系
     */
    @PreAuthorize("@ss.hasPermi('solution:solutionCategory:edit')")
    @Log(title = "方案分类关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody solutionCategory solutionCategory)
    {
        return toAjax(solutionCategoryService.updatesolutionCategory(solutionCategory));
    }

    /**
     * 删除方案分类关系
     */
    @PreAuthorize("@ss.hasPermi('solution:solutionCategory:remove')")
    @Log(title = "方案分类关系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{solutionIds}")
    public AjaxResult remove(@PathVariable Long[] solutionIds)
    {
        return toAjax(solutionCategoryService.deletesolutionCategoryBySolutionIds(solutionIds));
    }
}
